package com.imooc.es_demo.controller;

import com.imooc.es_demo.entity.mysql.MysqlBlog;
import com.imooc.es_demo.repository.mysql.MysqlBlogRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@Slf4j
public class IndexController {

    @Autowired
    private MysqlBlogRepository mysqlBlogRepository;

    @RequestMapping(value = {"","/index"})
    public String index(){
        List<MysqlBlog> all = mysqlBlogRepository.findAll();
        log.info(" size={}",all.size());
        for (MysqlBlog mysqlBlog : all) {
            log.info("---------mysqlBlog={}",mysqlBlog);
        }
        return "index.html";
    }
}
